hysop.core.arrays.array_backend module

class hysop.core.arrays.array_backend.ArrayBackend(allocator, **kwds)[source]

Bases: TaggedObject

Interface of an abstract array backend. An array backend is a numpy work-alike collection of functions that performs its computations on arrays on various devices.

Most of exposed functions should work exactly as in numpy, some default arguments are changed to match HySoP parameters (default ordering, default floating point type,

default integer type, default device, …)

All exposed functions are @classmethods, and this class cannot be instanciated.

Arithmetic methods, when available, should at least support the broadcasting of scalars.

See this link for more information about numpy routines: https://docs.scipy.org/doc/numpy/reference/routines.html

A backend implementation may expose subsets of the following routine sections (as listed on previous link):

  1. Array creation routines

  2. Array manipulation routines

  3. Binary operations

  4. Discrete Fourier Transform

  5. Functional programming

  6. Input and Output

  7. Linear Algebra

  8. Logic functions

  9. Mathematical functions

  10. Random sampling

  11. Set routines

  12. Sorting searching and counting

  13. Statistics

Currently unimplemented/unsupported features:
  1. String Operations

  2. C-Types Foreign Function Interface

  3. Datetime Support Functions

  4. Data type routines

  5. Optionally Scipy-accelerated routines

  6. Mathematical functions with automatic domain

  7. Floating point error handling

  8. NumPy-specific help functions

  9. Financial functions

  10. Indexing routines

  11. Masked Array operations

  12. Matrix library

  13. Miscellaneous routines

  14. Padding arrays

  15. Polynomials

  16. Test support

  17. Window functions

By default, all exposed methods raise a NotImplementedError with an explicit message through the _not_implemented_yet method.

Initialize an ArrayBackend with guven allocator.

absolute(x, out=None)[source]

Calculate the absolute value element-wise.

add(x1, x2, out=None)[source]

Add arguments element-wise.

all(a, axis=None, out=None)[source]

Test whether all array elements along a given axis evaluate to True.

allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[source]

Returns True if two arrays are element-wise equal within a tolerance.

property allocator

Get the allocated associated to this backend.

amax(a, axis=None, out=None)[source]

Return the maximum of an array or maximum along an axis.

amin(a, axis=None, out=None)[source]

Return the minimum of an array or minimum along an axis.

angle(z, deg=False)[source]

Return the angle of the complex argument.

any(a, axis=None, out=None)[source]

Test whether any array elements along a given axis evaluate to True.

any_backend_from_kind(*kinds)[source]
append(arr, values, axis=None)[source]

Append values to the end of an array.

apply_along_axis(func1d, axis, arr, *args, **kwargs)[source]

Apply a function to 1-D slices along the given axis.

apply_over_axes(func, a, axes)[source]

Apply a function repeatedly over multiple axes.

arange(dtype=<class 'numpy.int32'>, *args, **kargs)[source]

Return evenly spaced values within a given interval.

arccos(x, out=None)[source]

Trigonometric inverse cosine, element-wise.

arccosh(x, out=None)[source]

Inverse hyperbolic cosine, element-wise.

arcsin(x, out=None)[source]

Inverse sine, element-wise.

arcsinh(x, out=None)[source]

Inverse hyperbolic sine element-wise.

arctan(x, out=None)[source]

Trigonometric inverse tangent, element-wise.

arctan2(x1, x2, out=None)[source]

Element-wise arc tangent of x1/x2 choosing the quadrant correctly.

arctanh(x, out=None)[source]

Inverse hyperbolic tangent element-wise.

argmax(a, axis, out=None)[source]

Returns the indices of the maximum values along an axis.

argmin(a, axis, out=None)[source]

Returns the indices of the minimum values along an axis.

argpartition(a, kth, axis=-1, kind='quicksort', order=None)[source]

Perform an indirect partition along the given axis using the algorithm specified by the kind keyword.

argsort(a, axis=-1, kind='quicksort', order=None)[source]

Returns the indices that would sort an array.

argwhere(a)[source]

Find the indices of array elements that are non-zero, grouped by element.

around(a, decimals=0, out=None)[source]

Evenly round to the given number of decimals, returns HYSOP_INTEGER.

array(object, dtype=None, copy=True, order=C_CONTIGUOUS(0), subok=False, ndmin=0)[source]

Create an array.

array2string(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix='', style=<built-in function repr>, formatter=None)[source]

Return a string representation of an array.

array_equal(a1, a2)[source]

True if two arrays have the same shape and elements, False otherwise.

array_equiv(a1, a2)[source]

returns True if input arrays are shape consistent and all elements equal.

array_repr(arr, max_line_width=None, precision=None, supress_small=None)[source]

Return the string representation of an array.

array_split(ary, indices_or_sections, axis=0)[source]

Split an array into multiple sub-arrays.

array_str(a, max_line_width=None, precision=None, suppress_small=None)[source]

Return a string representation of the data in an array.

asanyarray(a, dtype=None, order=C_CONTIGUOUS(0))[source]

Convert the input to an ndarray, but pass ndarray subclasses through.

asarray(a, dtype=None, order=C_CONTIGUOUS(0), **kargs)[source]

Convert the input to an array.

asarray_chkfinite(a, dtype=None, order=C_CONTIGUOUS(0))[source]

Convert the input to an array, checking for NaNs or Infs.

asboolarray(a, order=C_CONTIGUOUS(0), **kargs)

Convert the input to an array of dtype HYSOP_BOOL.

ascomplexarray(a, order=C_CONTIGUOUS(0), **kargs)

Convert the input to an array of dtype HYSOP_COMPLEX.

ascontiguousarray(a, dtype=None)[source]

Return a contiguous array in memory (C order).

asdimarray(a, order=C_CONTIGUOUS(0), **kargs)

Convert the input to an array of dtype HYSOP_DIM.

asfortranarray(a, dtype=None)[source]

Return an array laid out in Fortran order in memory.

asindexarray(a, order=C_CONTIGUOUS(0), **kargs)

Convert the input to an array of dtype HYSOP_INDEX.

asintegerarray(a, order=C_CONTIGUOUS(0), **kargs)

Convert the input to an array of dtype HYSOP_INTEGER.

asmatrix(data, dtype=None)[source]

Interpret the input as a matrix.

asrealarray(a, order=C_CONTIGUOUS(0), **kargs)

Convert the input to an array of dtype HYSOP_REAL.

asscalar(a)[source]

Convert an array of size 1 to its scalar equivalent.

atleast_1d(*arys)[source]

Convert inputs to arrays with at least one dimension.

atleast_2d(*arys)[source]

View inputs as arrays with at least two dimensions.

atleast_3d(*arys)[source]

View inputs as arrays with at least three dimensions.

average(a, axis=None, weights=None, returned=False)[source]

Compute the weighted average along the specified axis.

base_repr(number, base=2, padding=0)[source]

Return a string representation of a number in the given base system.

beta(a, b, size=None)[source]

Draw samples from a Beta distribution.

binary_repr(num, width=None)[source]

Return the binary representation of the input number as a string.

bincount(x, weights=None, minlength=None)[source]

Count number of occurrences of each value in array of non-negative ints.

binomial(n, p, size=None)[source]

Draw samples from a binomial distribution.

bitwise_and(x1, x2, out=None)[source]

Compute the bit-wise AND of two arrays element-wise.

bitwise_or(x1, x2, out=None)[source]

Compute the bit-wise OR of two arrays element-wise.

bitwise_xor(x1, x2, out=None)[source]

Compute the bit-wise XOR of two arrays element-wise.

bool_empty(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape and type, without initializing entries.

bool_full(shape, fill_value, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with fill_value of type HYSOP_BOOL.

bool_ones(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape filled with ones of type HYSOP_BOOL.

bool_prod(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

bool_sum(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

bool_zeros(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with zeros of type HYSOP_BOOL.

broadcast_arrays(*args, **kwargs)[source]

Broadcast any number of arrays against each other.

broadcast_to(array, shape, subok=False)[source]

Broadcast an array to a new shape.

bytes(length)[source]

Return random bytes.

abstract can_wrap(handle, **kargs)[source]

Should return True if handle is an Array or a array handle corresponding this backend.

cbrt(x, out=None)[source]

Return the cube-root of an array, element-wise.

ceil(x, out=None)[source]

Return the ceiling of the input, element-wise.

chisquare(df, size=None)[source]

Draw samples from a chi-square distribution.

choice(a, size=None, replace=True, p=None)[source]

Generates a random sample from a given 1-D array

cholesky(a)[source]

Cholesky decomposition.

clip(a, a_min, a_max, out=None)[source]

Clip (limit) the values in an array.

column_stack(tup)[source]

Stack 1-D arrays as columns into a 2-D array.

complex_empty(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape and type, without initializing entries.

complex_full(shape, fill_value, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with fill_value of type HYSOP_COMPLEX.

complex_ones(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape filled with ones of type HYSOP_COMPLEX.

complex_prod(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

complex_sum(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

complex_zeros(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with zeros of type HYSOP_COMPLEX.

concatenate(a, axis=0)[source]

Join a sequence of arrays along an existing axis.

cond(x, p=None)[source]

Compute the condition number of a matrix.

conj(x, out=None)[source]

Return the complex conjugate, element-wise.

convolve(a, v, mode='full')[source]

Returns the discrete, linear convolution of two one-dimensional sequences.

copy(a, order=SAME_ORDER(3))[source]

Return an array copy of the given object.

copysign(x1, x2, out=None)[source]

Change the sign of x1 to that of x2, element-wise.

copyto(dst, src, **kargs)[source]

src is an Array dst can be everything

corrcoef(x, y, rowvar=1)[source]

Return Pearson product-moment correlation coefficients.

correlate(a, v, mode='valid')[source]

Cross-correlation of two 1-dimensional sequences.

cos(x, out=None)[source]

Cosine element-wise.

cosh(x, out=None)[source]

Hyperbolic cosine, element-wise.

count_nonzero(a, axis=None)[source]

Counts the number of non-zero values in the array a.

cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None)[source]

Estimate a covariance matrix, given data and weights.

cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None)[source]

Return the cross product of two (arrays of) vectors.

cumprod(a, axis=None, dtype=None, out=None)[source]

Return the cumulative product of elements along a given axis.

cumsum(a, axis=None, dtype=None, out=None)[source]

Return the cumulative sum of the elements along a given axis.

classmethod default_backend_from_kind(*kinds)[source]
deg2rad(x, out=None)[source]

Convert angles from degrees to radians.

degrees(x, out=None, **kargs)[source]

Convert angles from radians to degrees.

delete(arr, obj, axis=None)[source]

Return a new array with sub-arrays along an axis deleted.

det(a)[source]

Compute the determinant of an array.

diag(v, k=0)[source]

Extract a diagonal or construct a diagonal array.

diagflat(v, k=0)[source]

Create a two-dimensional array with the flattened input as a diagonal.

diff(a, n=1, axis=-1)[source]

Calculate the n-th discrete difference along given axis.

digitize(x, bins, right=False)[source]

Return the indices of the bins to which each value in input array belongs.

dim_empty(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape and type, without initializing entries.

dim_full(shape, fill_value, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with fill_value of type HYSOP_DIM.

dim_ones(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape filled with ones of type HYSOP_DIM.

dim_prod(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

dim_sum(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

dim_zeros(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with zeros of type HYSOP_DIM.

dirichlet(alpha, size=None)[source]

Draw samples from the Dirichlet distribution.

divide(x1, x2, out=None)[source]

Divide arguments element-wise.

dot(a, b, out=None)[source]

Dot product of two arrays.

dsplit(ary, indices_or_sections)[source]

Split array into multiple sub-arrays along the 3rd axis (depth).

dstack(tup)[source]

Stack arrays in sequence depth wise (along third axis).

ediff1d(ary, to_end=None, to_begin=None)[source]

The differences between consecutive elements of an array.

eig(a)[source]

Compute the eigenvalues and right eigenvectors of a square array.

eigh(a, UPLO='L')[source]

Return the eigenvalues and eigenvectors of a Hermitian or symmetric matrix.

eigvals(a)[source]

Compute the eigenvalues of a general matrix.

eigvalsh(a, UPLO='L')[source]

Compute the eigenvalues of a Hermitian or real symmetric matrix.

einsum(subscripts, out=None, dtype=None, order=SAME_ORDER(3), casting='safe', optimize=False, *operands)[source]

Evaluates the Einstein summation convention on the operands.

empty(shape, dtype=<class 'numpy.float64'>, order=C_CONTIGUOUS(0))[source]

Return a new array of given shape and type, without initializing entries.

empty_like(a, dtype=None, order=SAME_ORDER(3), subok=True, shape=None)[source]

Return a new array with the same shape and type as a given array.

equal(x1, x2, out=None)[source]

Return (x1 == x2) element-wise.

exp(x, out=None)[source]

Calculate the exponential of all elements in the input array.

exp2(x, out=None)[source]

Calculate 2**p for all p in the input array.

expand_dims(a, axis)[source]

Expand the shape of an array.

expm1(x, out=None)[source]

Calculate exp(x) - 1 for all elements in the array.

exponential(scale=1.0, size=None)[source]

Draw samples from an exponential distribution.

extract(condition, arr)[source]

Return the elements of an array that satisfy some condition.

eye(N, M, k, dtype=None)[source]

Return a 2-D array with ones on the diagonal and zeros elsewhere.

f(dfnum, dfden, size=None)[source]

Draw samples from an F distribution.

fabs(x, out=None)[source]

Calculate the absolute value element-wise, outputs HYSOP_REAL unless out is set.

fft(a, n=None, axis=-1, norm=None)[source]

Compute the one-dimensional discrete Fourier Transform.

fft2(a, s=None, axes=None, norm=None)[source]

Compute the 2-dimensional discrete Fourier Transform

fftfreq(n=None, d=1.0)[source]

Return the Discrete Fourier Transform sample frequencies.

fftn(a, s=None, axes=None, norm=None)[source]

Compute the N-dimensional discrete Fourier Transform.

fftshift(x, axes=None)[source]

Shift the zero-frequency component to the center of the spectrum.

fill(a, value)[source]

Fill the array with given value

fix(x, y=None)[source]

Round to nearest integer towards zero.

flatnonzero(a)[source]

Return indices that are non-zero in the flattened version of a.

flip(m, axis)[source]

Reverse the order of elements in an array along the given axis.

fliplr(m)[source]

Flip array in the left/right direction.

flipud(m)[source]

Flip array in the up/down direction.

floor(x, out=None)[source]

Return the floor of the input, element-wise.

floor_divide(x1, x2, out=None)[source]

Return the largest integer smaller or equal to the division of the inputs.

fmax(x1, x2, out=None)[source]

Element-wise minimum of array elements, ignore NaNs.

fmin(x1, x2, out=None)[source]

Element-wise maximum of array elements, ignore NaNs.

fmod(x1, x2, out=None)[source]

Return the element-wise remainder of division (REM). Remainder has the same sign as the divisor x2. This should not be confused with the Python modulus operator x1 % x2.

frexp(x, out1=None, out2=None)[source]

Decompose the elements of x into mantissa and twos exponent.

frombuffer(afer, dtype=<class 'numpy.float64'>, count=-1, offset=0)[source]

Interpret a afer as a 1-dimensional array.

fromfile(file, dtype=<class 'numpy.float64'>, count=-1, sep='')[source]

Construct an array from data in a text or binary file.

fromfunction(function, shape, dtype=<class 'numpy.float64'>)[source]

Construct an array by executing a function over each coordinate.

fromiter(iterable, dtype=<class 'numpy.float64'>, count=-1)[source]

Create a new 1-dimensional array from an iterable object.

frompyfunc(func, nin, nout)[source]

Takes an arbitrary Python function and returns a NumPy ufunc.

fromregex(file, regexp, dtype)[source]

Construct an array from a text file, using regular expression parsing.

fromstring(string, dtype=<class 'numpy.float64'>, count=-1, sep='')[source]

A new 1-D array initialized from raw binary or text data in a string.

full(shape, fill_value, dtype=None, order=C_CONTIGUOUS(0))[source]

Return a new array of given shape and type, filled with fill_value.

full_like(a, fill_value, dtype=None, order=SAME_ORDER(3), subok=True, shape=None)[source]

Return a full array with the same shape and type as a given array.

gamma(shape, scale=1.0, size=None)[source]

Draw samples from a Gamma distribution.

genfromtxt(fname, dtype=<class 'numpy.float64'>, comments='#', delimiter=None, skip_header=0, skip_footer=0, converters=None, missing_values=None, filling_values=None, usecols=None, names=None, excludelist=None, deletechars=None, replace_space='_', autostrip=False, case_sensitive=True, defaultfmt='f%i', unpack=None, usemask=False, loose=True, invalid_raise=True, max_rows=None)[source]

Load data from a text file, with missing values handled as specified.

geometric(p, size=None)[source]

Draw samples from the geometric distribution.

geomspace(start, stop, num=50, endpoint=True, dtype=<class 'numpy.float64'>)[source]

Return numbers spaced evenly on a log scale (a geometric progression).

static get_alignment_and_size(shape, dtype, min_alignment=None)[source]

Returns number of bytes to allocate an array of given shape and given dtype, aligned on given alignment. Returned alignment will be at least dtype.itemsize. Alignment should non zero and a power of two, or None in which case it will be set to 1.

get_allocator()[source]

Get the allocated associated to this backend.

abstract get_host_array_backend()[source]
classmethod get_or_create(**kwds)[source]
get_printoptions()[source]

Return the current print options.

get_state()[source]

Return a tuple representing the internal state of the generator.

gradient(f, *varargs, **kwargs)[source]

Return the gradient of an N-dimensional array.

greater(x1, x2, out=None)[source]

Return the truth value of (x1 > x2) element-wise.

greater_equal(x1, x2, out=None)[source]

Return the truth value of (x1 >= x2) element-wise.

gumbel(loc=0.0, scale=1.0, size=None)[source]

Draw samples from a Gumbel distribution.

hfft(a, n=None, axis=-1, norm=None)[source]

Compute the FFT of a signal that has Hermitian symmetry, i.e., a real spectrum.

histogram(a, bins=10, range=None, normed=False, weights=None, density=None)[source]

Compute the histogram of a set of data.

histogram2d(x, y, bins, range=None, normed=False, weights=None)[source]

Compute the bi-dimensional histogram of two data samples.

histogramdd(sample, bins, range=None, normed=False, weights=None)[source]

Compute the multidimensional histogram of some data.

abstract property host_array_backend
hsplit(ary, indices_or_sections)[source]

Split an array into multiple sub-arrays horizontally (column-wise).

hstack(tup)[source]

Stack arrays in sequence horizontally (column wise).

hypergeometric(ngood, nbad, nsample, size=None)[source]

Draw samples from a Hypergeometric distribution.

hypot(x1, x2, out=None)[source]

Given the legs of a right triangle, return its hypotenuse.

i0(x)[source]

Modified Bessel function of the first kind, order 0.

identity(n, dtype=None)[source]

Return the identity array.

ifft(a, n=None, axis=-1, norm=None)[source]

Compute the one-dimensional inverse discrete Fourier Transform.

ifft2(a, s=None, axes=None, norm=None)[source]

Compute the 2-dimensional inverse discrete Fourier Transform.

ifftn(a, s=None, axes=None, norm=None)[source]

Compute the N-dimensional inverse discrete Fourier Transform.

ifftshift(x, axes=None)[source]

The inverse of fftshift.

ihfft(a, n=None, axis=-1, norm=None)[source]

Compute the inverse FFT of a signal that has Hermitian symmetry.

imag(val)[source]

Return the imaginary part of the elements of the array.

in1d(ar1, ar2, assume_unique=False, invert=False)[source]

Test whether each element of a 1-D array is also present in a second array.

index_empty(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape and type, without initializing entries.

index_full(shape, fill_value, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with fill_value of type HYSOP_INDEX.

index_ones(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape filled with ones of type HYSOP_INDEX.

index_prod(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

index_sum(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

index_zeros(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with zeros of type HYSOP_INDEX.

inner(a, b)[source]

Inner product of two arrays.

insert(arr, obj, values, axis=None)[source]

Insert values along the given axis before the given indices.

integer_empty(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape and type, without initializing entries.

integer_full(shape, fill_value, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with fill_value of type HYSOP_INTEGER.

integer_ones(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape filled with ones of type HYSOP_INTEGER.

integer_prod(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

integer_sum(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

integer_zeros(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with zeros of type HYSOP_INTEGER.

interp(x, xp, fp, left=None, right=None, period=None)[source]

One-dimensional linear interpolation.

intersect1d(ar1, ar2, assume_unique=False)[source]

Find the intersection of two arrays.

inv(a)[source]

Compute the (multiplicative) inverse of a matrix.

invert(x, out=None)[source]

Compute bit-wise inversion, or bit-wise NOT, element-wise.

irfft(a, n=None, axis=-1, norm=None)[source]

Compute the inverse of the n-point DFT for real input.

irfft2(a, s=None, axes=(-2, -1), norm=None)[source]

Compute the 2-dimensional inverse FFT of a real array.

irfftn(a, s=None, axes=None, norm=None)[source]

Compute the inverse of the N-dimensional FFT of real input.

isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[source]

Returns a boolean array where two arrays are element-wise equal within a tolerance.

isfinite(x, out=None)[source]

Test element-wise for finiteness (not infinity or not Not a Number).

isinf(x, out=None)[source]

Test element-wise for positive or negative infinity.

isnan(x, out=None)[source]

Test element-wise for NaN and return result as a boolean array.

isneginf(x, out=None)[source]

Test element-wise for negative infinity, return result as bool array.

isposinf(x, out=None)[source]

Test element-wise for positive infinity, return result as bool array.

kron(a, b)[source]

Kronecker product of two arrays.

laplace(loc=0.0, scale=1.0, size=None)[source]

Draw samples from the Laplace or double exponential distribution with specified location (or mean=0.0) and scale (decay).

ldexp(x1, x2, out=None)[source]

Returns x1 * 2**x2, element-wise.

left_shift(x1, x2, out=None)[source]

Shift the bits of an integer to the left.

less(x1, x2, out)[source]

Return the truth value of (x1 < x2) element-wise.

less_equal(x1, x2, out)[source]

Return the truth value of (x1 =< x2) element-wise.

lexsort(keys, axis=-1)[source]

Perform an indirect sort using a sequence of keys.

linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=<class 'numpy.float64'>)[source]

Return evenly spaced numbers over a specified interval.

load(mmap_mode=None, allow_pickle=True, fix_imports=True, encoding='ASCII')[source]

Load arrays or pickled objects from .npy, .npz or pickled files.

loadtxt(dtype=<class 'numpy.float64'>, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0)[source]

Load data from a text file.

log(x, out=None)[source]

Natural logarithm, element-wise.

log10(x, out=None)[source]

Return the base 10 logarithm of the input array, element-wise.

log1p(x, out=None)[source]

Return the natural logarithm of one plus the input array, element-wise.

log2(x, out=None)[source]

Base-2 logarithm of x.

logaddexp(x1, x2, out=None)[source]

Logarithm of the sum of exponentiations of the inputs.

logaddexp2(x1, x2, out=None)[source]

Logarithm of the sum of exponentiations of the inputs in base-2.

logical_and(x1, x2, out=None)[source]

Compute the truth value of x1 AND x2 element-wise.

logical_not(x, out=None)[source]

Compute the truth value of NOT x element-wise.

logical_or(x1, x2, out=None)[source]

Compute the truth value of x1 OR x2 element-wise.

logical_xor(x1, x2, out=None)[source]

Compute the truth value of x1 XOR x2, element-wise.

logistic(loc=0.0, scale=1.0, size=None)[source]

Draw samples from a logistic distribution.

lognormal(mean=0.0, sigma=1.0, size=None)[source]

Draw samples from a log-normal distribution.

logseries(p, size=None)[source]

Draw samples from a logarithmic series distribution.

logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=<class 'numpy.float64'>)[source]

Return numbers spaced evenly on a log scale.

lstsq(a, b, rcond=-1)[source]

Return the least-squares solution to a linear matrix equation.

matmul(a, b, out=None)[source]

Matrix product of two arrays.

matrix_power(M, n)[source]

Raise a square matrix to the integer power n.

matrix_rank(M, tol=None)[source]

Return matrix rank of array using SVD method

property max_alloc_size

Get the maximal size of allocatable contiguous chunk of memory in bytes.

maximum(x1, x2, out=None)[source]

Element-wise maximum of array elements.

mean(a, axis=None, dtype=None, out=None)[source]

Compute the arithmetic mean along the specified axis.

median(a, axis=None, out=None, overwrite_input=False)[source]

Compute the median along the specified axis.

memcpy(dst, src, **kargs)[source]

Copy memory from src buffer to dst buffer .

meshgrid(*xi, **kwargs)[source]

Return coordinate matrices from coordinate vectors.

minimum(x1, x2, out=None)[source]

Element-wise minimum of array elements.

mod(x1, x2, out=None)[source]

Return element-wise remainder of division (MOD). Remainder has the same sign as the divident x1. It is complementary to the function floor_divide and match Python modfulus operator x1 % x2.

modf(x, out1=None, out2=None)[source]

Return the fractional and integral parts of an array, element-wise.

moveaxis(a, source, destination)[source]

Move axes of an array to new positions. Axe 0 is the slowest varying index, last axe is the fastest varying index.

msort(a)[source]

Return a copy of an array sorted along the first axis.

multinomial(n, pvals, size=None)[source]

Draw samples from a multinomial distribution.

multiply(x1, x2, out=None)[source]

Multiply arguments element-wise.

multivariate_normal(mean, cov, size=None)[source]

Draw random samples from a multivariate normal distribution.

nan_to_num(x)[source]

Replace nan with zero and inf with finite numbers.

nanargmax(a, axis=None)[source]

Return the indices of the maximum values in the specified axis ignoring NaNs.

nanargmin(a, axis=None)[source]

Return the indices of the minimum values in the specified axis ignoring NaNs.

nancumprod(a, axis=None, dtype=None, out=None)[source]

Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one.

nancumsum(a, axis=None, dtype=None, out=None)[source]

Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.

nanmax(a, axis=None, out=None)[source]

Return the maximum of an array or maximum along an axis, ignoring any NaNs.

nanmean(a, axis=None, dtype=None, out=None)[source]

Compute the arithmetic mean along the specified axis, ignoring NaNs.

nanmedian(a, axis=None, out=None, overwrite_input=False)[source]

Compute the median along the specified axis, while ignoring NaNs.

nanmin(a, axis=None, out=None)[source]

Return minimum of an array or minimum along an axis, ignoring any NaNs.

nanpercentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear')[source]

Compute the qth percentile of the data along the specified axis, while ignoring nan values.

nanprod(a, axis=None, dtype=None, out=None)[source]

Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.

nanstd(a, axis=None, dtype=None, out=None, ddof=0)[source]

Compute the standard deviation along the specified axis, while ignoring NaNs.

nansum(a, axis=None, dtype=None, out=None)[source]

Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.

nanvar(a, axis=None, dtype=None, out=None, ddof=0)[source]

Compute the variance along the specified axis, while ignoring NaNs.

negative(x, out=None)[source]

Numerical negative, element-wise.

negative_binomial(n, p, size=None)[source]

Draw samples from a negative binomial distribution.

noncentral_chisquare(df, nonc, size=None)[source]

Draw samples from a noncentral chi-square distribution.

noncentral_f(dfnum, dfden, nonc, size=None)[source]

Draw samples from the noncentral F distribution.

nonzero(a)[source]

Return the indices of the elements that are non-zero.

norm(x, ord=None, axis=None, keepdims=False)[source]

Matrix or vector norm.

normal(loc=0.0, scale=1.0, size=None)[source]

Draw random samples from a normal (Gaussian) distribution.

not_equal(x1, x2, out=None)[source]

Return (x1 != x2) element-wise.

ones(shape, dtype=None, order=C_CONTIGUOUS(0))[source]

Return a new array of given shape and type, filled with ones.

ones_like(a, dtype=None, order=SAME_ORDER(3), subok=True, shape=None)[source]

Return an array of ones with the same shape and type as a given array.

outer(a, b, out=None)[source]

Compute the outer product of two vectors.

packbits(myarray, axis=None)[source]

Packs the elements of a binary-valued array into bits in a uint8 array.

pareto(a, size=None)[source]

Draw samples from a Pareto II or Lomax distribution with specified shape.

partition(a, kth, axis=-1, kind='quicksort', order=None)[source]

Return a partitioned copy of an array.

percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear')[source]

Compute the qth percentile of the data along the specified axis.

permutation(x)[source]

Randomly permute a sequence, or return a permuted range.

piecewise(x, condlist, funclist, *args, **kw)[source]

Evaluate a piecewise-defined function.

pinv(a, rcond=1e-15)[source]

Compute the (Moore-Penrose) pseudo-inverse of a matrix.

poisson(lam, size=None)[source]

Draw samples from a Poisson distribution.

power(x1, x2, out=None)[source]

First array elements raised to powers from second array, element-wise.

prod(a, axis=None, dtype=None, out=None)[source]

Return the product of array elements over a given axis.

ptp(a, axis=None, out=None)[source]

Range of values (maximum - minimum) along an axis.

qr(a, mode='reduced')[source]

Compute the qr factorization of a matrix.

rad2deg(x, out=None)[source]

Convert angles from radians to degrees.

radians(x, out=None, **kargs)[source]

Convert angles from degrees to radians.

rand(shape, **kwds)[source]

Random values in a given shape between 0.0 and 1.0.

randint(low, high=None, size=None, dtype=<class 'numpy.int32'>)[source]

Return random integers from low (inclusive) to high (exclusive).

randn(shape, **kwds)[source]

Return a sample (or samples) from the ‘standard normal’ distribution.

random(size=None)[source]

Return random floats in the half-open interval 0.0, 1.0).

random_integers(low, high=None, size=None)[source]

Random integers of type np.int between low and high, inclusive.

random_sample(size=None)[source]

Return random floats in the half-open interval 0.0, 1.0).

ranf(size=None)[source]

Return random floats in the half-open interval 0.0, 1.0).

ravel(a, order=SAME_ORDER(3))[source]

Return a contiguous flattened array.

rayleigh(scale=1.0, size=None)[source]

Draw samples from a Rayleigh distribution.

real(val)[source]

Return the real part of the elements of the array.

real_empty(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape and type, without initializing entries.

real_full(shape, fill_value, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with fill_value of type HYSOP_REAL.

real_if_close(a, tol=100)[source]

If complex input returns a real array if complex parts are close to zero.

real_ones(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape filled with ones of type HYSOP_REAL.

real_prod(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

real_sum(a, axis=None, out=None, **kargs)

Sum of array elements over a given axis.

real_zeros(shape, order=C_CONTIGUOUS(0), **kargs)

Return a new array of given shape, filled with zeros of type HYSOP_REAL.

reciprocal(x, out=None)[source]

Return the reciprocal of the argument, element-wise.

remainder(x1, x2, out=None, **kargs)[source]

Return element-wise remainder of division (MOD). Remainder has the same sign as the divisor x2. match Python modfulus operator x1 % x2. Returns x - y*floor(x/y)

repeat(a, repeats, axis=None)[source]

Repeat elements of an array.

require(a, dtype=None, requirements=None)[source]

Return an ndarray of the provided type that satisfies requirements.

reshape(a, newshape, order=C_CONTIGUOUS(0))[source]

Gives a new shape to an array without changing its data.

resize(a, new_shape)[source]

Return a new array with the specified shape.

rfft(a, n=None, axis=-1, norm=None)[source]

Compute the one-dimensional discrete Fourier Transform for real input.

rfft2(a, s=None, axes=(-2, -1), norm=None)[source]

Compute the 2-dimensional FFT of a real array.

rfftfreq(n=None, d=1.0)[source]

Return the Discrete Fourier Transform sample frequencies (for usage with rfft, irfft).

rfftn(a, s=None, axes=None, norm=None)[source]

Compute the N-dimensional discrete Fourier Transform for real input.

right_shift(x1, x2, out=None)[source]

Shift the bits of an integer to the right.

rint(x, out=None)[source]

Round elements of the array to the nearest integer.

roll(a, shift, axis=None)[source]

Roll array elements along a given axis.

rollaxis(a, axis, start=0)[source]

Roll the specified axis backwards, until it lies in a given position. Axe 0 is the slowest varying index, last axe is the fastest varying index.

rot90(m, k=1, axes=(0, 1))[source]

Rotate an array by 90 degrees in the plane specified by axes.

sample(size=None)[source]

Return random floats in the half-open interval 0.0, 1.0).

save(arr, file, allow_pickle=True, fix_imports=True)[source]

Save an array to a binary file in NumPy .npy format.

savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# ')[source]

Save an array to a text file.

savez(file, *args, **kwds)[source]

Save several arrays into a single file in uncompressed .npz format.

savez_compressed(file, *args, **kwds)[source]

Save several arrays into a single file in compressed .npz format.

searchsorted(a, v, side='left', sorter=None)[source]

Find indices where elements should be inserted to maintain order.

seed(seed=None)[source]

Seed the generator.

set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None, formatter=None)[source]

Set printing options.

set_state(state)[source]

Set the internal state of the generator from a tuple.

set_string_function(f, repr=True)[source]

Set a Python function to be used when pretty printing arrays.

setdiff1d(ar1, ar2, assume_unique=False)[source]

Find the set difference of two arrays.

setxor1d(ar1, ar2, assume_unique=False)[source]

Find the set exclusive-or of two arrays.

abstract short_description()[source]
shuffle(x)[source]

Modify a sequence in-place by shuffling its contents.

sign(x, out=None)[source]

Returns an element-wise indication of the sign of a number.

signbit(x, out=None)[source]

Returns element-wise True where signbit is set (less than zero).

sin(x, out=None)[source]

Trigonometric sine, element-wise.

sinc(x)[source]

Return the sinc function.

sinh(x, out=None)[source]

Hyperbolic sine, element-wise.

slogdet(a)[source]

Compute the sign and natural logarithm of the determinant of an array.

solve(a, b)[source]

Solve a linear matrix equation, or system of linear scalar equations.

sort(a, axis=-1, kind='quicksort', order=None)[source]

Return a sorted copy of an array.

sort_complex(a)[source]

Sort a complex array using the real part first, then the imaginary part.

split(ary, indices_or_sections, axis=0)[source]

Split an array into multiple sub-arrays.

sqrt(x, out=None)[source]

Return the positive square-root of an array, element-wise.

square(x, out=None)[source]

Return the element-wise square of the input.

squeeze(a, axis=None)[source]

Remove single-dimensional entries from the shape of an array.

stack(arrays, axis=0)[source]

Join a sequence of arrays along a new axis.

standard_cauchy(size=None)[source]

Draw samples from a standard Cauchy distribution with mode = 0.

standard_exponential(size=None)[source]

Draw samples from the standard exponential distribution.

standard_gamma(shape, size=None)[source]

Draw samples from a standard Gamma distribution.

standard_normal(size=None)[source]

Draw samples from a standard Normal distribution (mean=0.0, stdev=1).

standard_t(df, size=None)[source]

Draw samples from a standard Student’s t distribution with df degrees of freedom.

std(a, axis=None, dtype=None, out=None, ddof=0)[source]

Compute the standard deviation along the specified axis.

subtract(x1, x2, out=None)[source]

Subtract arguments, element-wise.

sum(a, axis=None, dtype=None, out=None)[source]

Sum of array elements over a given axis.

svd(a, full_matrices=True, compute_uv=True)[source]

Singular Value Decomposition.

swapaxes(a, axis1, axis2)[source]

Interchange two axes of an array. Axe 0 is the slowest varying index, last axe is the fastest varying index.

tan(x, out=None)[source]

Compute tangent element-wise.

tanh(x, out=None)[source]

Compute hyperbolic tangent element-wise.

tensordot(a, b, axes=2)[source]

Compute tensor dot product along specified axes for arrays >= 1-D.

tensorinv(a, ind=2)[source]

Compute the ‘inverse’ of an N-dimensional array.

tensorsolve(a, b, axes=None)[source]

Solve the tensor equation a x = b for x.

tile(A, reps)[source]

Construct an array by repeating A the number of times given by reps.

trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None)[source]

Return the sum along diagonals of the array.

transpose(a, axes=None)[source]

Permute the dimensions of an array. Axe 0 is the slowest varying index, last axe is the fastest varying index. Default permutation is (0,…,ndim-1).

trapz(y, x=None, dx=1.0, axis=-1)[source]

Integrate along the given axis using the composite trapezoidal rule.

tri(N, M=None, k=0, dtype=<class 'numpy.float64'>)[source]

An array with ones at and below the given diagonal and zeros elsewhere.

triangular(left, mode, right, size=None)[source]

Draw samples from the triangular distribution over the interval left, right.

tril(m, k)[source]

Lower triangle of an array.

trim_zeros(filt, trim='fb')[source]

Trim the leading and/or trailing zeros from a 1-D array or sequence.

triu(m, k=0)[source]

Upper triangle of an array.

true_divide(x1, x2, out=None)[source]

Returns a true division of the inputs, element-wise.

trunc(x, out=None)[source]

Return the truncated value of the input, element-wise.

uniform(low, high, size=None)[source]

Draw samples from a uniform distribution.

union1d(ar1, ar2)[source]

Find the union of two arrays.

unique(ar, return_index=False, return_inverse=False, return_counts=False)[source]

Find the unique elements of an array.

unpackbits(myarray, axis=None)[source]

Unpacks elements of a uint8 array into a binary-valued output array.

unwrap(p, discont=3.141592653589793, axis=-1)[source]

Unwrap by changing deltas between values to 2*pi complement.

vander(x, N=None, increasing=False)[source]

Generate a Vandermonde matrix.

var(a, axis=None, dtype=None, out=None, ddof=0)[source]

Compute the variance along the specified axis.

vdot(a, b)[source]

Return the dot product of two vectors.

vectorize(pyfunc, otypes=None, doc=None, excluded=None, cache=False, signature=None)[source]

Generalized function class.

vonmises(mu, kappa, size=None)[source]

Draw samples from a von Mises distribution.

vsplit(ary, indices_or_sections)[source]

Split an array into multiple sub-arrays vertically (row-wise).

vstack(tup)[source]

Stack arrays in sequence vertically (row wise).

wald(mean=0.0, scale=1.0, size=None)[source]

Draw samples from a Wald, or inverse Gaussian, distribution.

weibull(a, size=None)[source]

Draw samples from a Weibull distribution.

where(condition, x, y)[source]

Return elements, either from x or y, depending on condition.

abstract wrap(handle, **kargs)[source]

Create a backend specific Array from the corresponding array handle.

zeros(shape, dtype=None, order=C_CONTIGUOUS(0))[source]

Return a new array of given shape and type, filled with zeros.

zeros_like(a, dtype=None, order=SAME_ORDER(3), subok=True, shape=None)[source]

Return an array of zeros with the same shape and type as a given array.

zipf(a, size=None)[source]

Draw samples from a Zipf distribution.